from sqlalchemy import create_engine,text

def conn_db1():
    HOST="127.0.0.1"
    PORT=3306
    DATA_BASE='falsk_sb'
    USER='root'
    PWD='root'
    # DB_URL=f'数据库的名+驱动名://{USER}:{PWD}@{HOST}:{PORT}/{DATA_BASE}'
    DB_URL=f'mysql+pymysql://{USER}:{PWD}@localhost/{DATA_BASE}'
    print(DB_URL)
    engine=create_engine(DB_URL)
    # 执行一个sql
    sql='CREATE TABLE user(id int NOT NULL PRIMARY KEY AUTO_INCREMENT,name VARCHAR(30));'
    con=engine.connect()
    con.execute(text(sql))
conn_db1()